package com.nine.shop.utils;


import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 格式化时间
 *
 * @author chenyi
 * date create on 2019/4/21
 */
public class DateFormatUtil {
    private static final SimpleDateFormat SDF_FULL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private static final SimpleDateFormat SDF_FULL_UTF = new SimpleDateFormat("yyyyMMddHHmmss");
    //getOnlyDay使用
    private static final SimpleDateFormat SDF_OnlyDay = new SimpleDateFormat("yyyy-MM-dd");

    //获取当天日期
    public static String getOnlyDayTime() {
        return SDF_OnlyDay.format(new Date());
    }

    public static String getFullDayTime(){
        return SDF_FULL_UTF.format(new Date());
    }

    public static String getMysqlDayTime(){return SDF_FULL.format(new Date());}

    /**
     * 字符串转时间
     */
    public static String str2Date(Date date){
        return SDF_FULL.format(date);
    }

}
